package com.ruoyi.project.member.aicoinpackage.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.framework.aspectj.lang.annotation.DataSource;
import com.ruoyi.framework.aspectj.lang.enums.DataSourceType;
import com.ruoyi.project.member.aicoinpackage.domain.AicoinPackage;
import com.ruoyi.project.member.aicoinpackage.mapper.AicoinPackageMapper;
import com.ruoyi.project.member.aicoinpackage.service.IAicoinPackageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * AI币套餐Service业务层处理
 *
 * @author shixiangwen
 * @date 2023-06-13
 */
@Service
@DataSource(DataSourceType.ACCOUNT)
public class AicoinPackageServiceImpl implements IAicoinPackageService {
    @Autowired
    private AicoinPackageMapper aicoinPackageMapper;

    /**
     * 查询AI币套餐
     *
     * @param id AI币套餐ID
     * @return AI币套餐
     */
    @Override
    public AicoinPackage selectAicoinPackageById(Long id) {
        return aicoinPackageMapper.selectAicoinPackageById(id);
    }

    /**
     * 查询AI币套餐列表
     *
     * @param aicoinPackage AI币套餐
     * @return AI币套餐
     */
    @Override
    public List<AicoinPackage> selectAicoinPackageList(AicoinPackage aicoinPackage) {
        return aicoinPackageMapper.selectAicoinPackageList(aicoinPackage);
    }

    /**
     * 新增AI币套餐
     *
     * @param aicoinPackage AI币套餐
     * @return 结果
     */
    @Override
    public int insertAicoinPackage(AicoinPackage aicoinPackage) {
        aicoinPackage.setCreateTime(DateUtils.getNowDate());
        aicoinPackage.setCreateBy(ShiroUtils.getLoginName());
        return aicoinPackageMapper.insertAicoinPackage(aicoinPackage);
    }

    /**
     * 修改AI币套餐
     *
     * @param aicoinPackage AI币套餐
     * @return 结果
     */
    @Override
    public int updateAicoinPackage(AicoinPackage aicoinPackage) {
        aicoinPackage.setUpdateTime(DateUtils.getNowDate());
        aicoinPackage.setUpdateBy(ShiroUtils.getLoginName());
        return aicoinPackageMapper.updateAicoinPackage(aicoinPackage);
    }

    /**
     * 删除AI币套餐对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteAicoinPackageByIds(String ids) {
        return aicoinPackageMapper.deleteAicoinPackageByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除AI币套餐信息
     *
     * @param id AI币套餐ID
     * @return 结果
     */
    @Override
    public int deleteAicoinPackageById(Long id) {
        return aicoinPackageMapper.deleteAicoinPackageById(id);
    }
}
